package gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * @author Matthias
 *
 */
public class AccAccountInfo extends JPanel{
	
	private JLabel lbl_Header;
	private JButton btn_Back;
	private JTextField textField_AccNr;
	private JTextField textField_accType;
	private JTextField textField_totBalance;
	private JButton btn_GetInfo;
	private JLabel lbl_AccNr;
	private JLabel lbl_AccountType;
	private JLabel lbl_TotalBalance;
	private JTextField textField_InterestRate;
	private JLabel lbl_InterestRate;
	
	public AccAccountInfo() {
		
		setPreferredSize(new Dimension(550, 400));
		setLayout(null);
		
		lbl_Header = new JLabel("Account Info of current Account");
		lbl_Header.setFont(new Font("SansSerif", Font.BOLD, 26));
		lbl_Header.setBounds(81, 30, 399, 34);
		add(lbl_Header);
		
		btn_Back = new JButton("Back");
		btn_Back.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Back.setBounds(66, 300, 100, 40);
		add(btn_Back);
		
		textField_accType = new JTextField();
		textField_accType.setHorizontalAlignment(SwingConstants.CENTER);
		textField_accType.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		textField_accType.setEditable(false);
		textField_accType.setBounds(235, 144, 180, 30);
		add(textField_accType);
		textField_accType.setColumns(10);
		
		textField_totBalance = new JTextField();
		textField_totBalance.setHorizontalAlignment(SwingConstants.CENTER);
		textField_totBalance.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		textField_totBalance.setEditable(false);
		textField_totBalance.setBounds(235, 230, 180, 30);
		add(textField_totBalance);
		textField_totBalance.setColumns(10);
		
		textField_AccNr = new JTextField();
		textField_AccNr.setHorizontalAlignment(SwingConstants.CENTER);
		textField_AccNr.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		textField_AccNr.setEditable(false);
		textField_AccNr.setBounds(235, 100, 180, 30);
		add(textField_AccNr);
		textField_AccNr.setColumns(10);
		
		btn_GetInfo = new JButton("Get Info!");
		btn_GetInfo.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_GetInfo.setBounds(380, 300, 100, 40);
		add(btn_GetInfo);
		
		lbl_AccNr = new JLabel("Acc Nr");
		lbl_AccNr.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_AccNr.setBounds(149, 104, 51, 21);
		add(lbl_AccNr);
		
		lbl_AccountType = new JLabel("Account Type");
		lbl_AccountType.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_AccountType.setBounds(94, 148, 106, 21);
		add(lbl_AccountType);
		
		lbl_TotalBalance = new JLabel("Total Balance");
		lbl_TotalBalance.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_TotalBalance.setBounds(96, 234, 104, 21);
		add(lbl_TotalBalance);
		
		textField_InterestRate = new JTextField();
		textField_InterestRate.setHorizontalAlignment(SwingConstants.CENTER);
		textField_InterestRate.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		textField_InterestRate.setBounds(235, 189, 180, 30);
		textField_InterestRate.setEditable(false);
		add(textField_InterestRate);
		textField_InterestRate.setColumns(10);
		
		lbl_InterestRate = new JLabel("Interest Rate");
		lbl_InterestRate.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_InterestRate.setBounds(104, 193, 96, 21);
		add(lbl_InterestRate);
	}
	
	public void addActionListener(ActionListener e){
		btn_Back.addActionListener(e);
		btn_GetInfo.addActionListener(e);
	}
	
	public void showFields (int AccNr, String accountType, double InterestRate, double totalBalance) {
		textField_AccNr.setText("" + AccNr);
		textField_accType.setText("" + accountType);
		textField_InterestRate.setText("" + InterestRate);
		textField_totBalance.setText("" + totalBalance);
	}
	
	public void clearFields() {
		textField_AccNr.setText("");
		textField_accType.setText("");
		textField_InterestRate.setText("");
		textField_totBalance.setText("");
	}
	
	public JButton getBtnBack(){
		return btn_Back;
	}
	
	public JButton getBtnAccountInfo() {
		return btn_GetInfo;
	}
}
